﻿using UnityEngine;
using System.Collections;

/// <summary>
/// 基础状态
/// </summary>
public class GameStateBase {

    /// <summary>
    /// 进入状态
    /// </summary>
    public virtual void Enter()
    {

    }

    /// <summary>
    /// 离开状态
    /// </summary>
    public virtual void Leave()
    {

    }

    /// <summary>
    /// 处理数据包
    /// </summary>
    /// <param name="message"></param>
    /// <returns></returns>
    public virtual bool ProcessPacket(IOMessage message)
    {
        switch(message.code)
        {
            case IOCmds.SMSG_SET_PLAYER_OFFLINE:
                GameDataKernel.inst.HandleMessage(message);
                return true;
        }

        return false;
    }

    /// <summary>
    /// 请求加入房间
    /// </summary>
    protected void RequestJoinRoom()
    {
        Hashtable args = new Hashtable();
        args["roomId"] = GameDataKernel.inst.roomId;
        args["uid"] = DataKernel.inst.userInfo.uid;
        args["name"] = DataKernel.inst.userInfo.name;
        args["headpic"] = DataKernel.inst.userInfo.headpic;
        args["sex"] = DataKernel.inst.userInfo.sex;
        NetIOController.inst.SendMessage(
            new IOMessage(IOCmds.CMSG_JOIN_ROOM, 0, new HashtableEx(args))
            );
    }
}
